package calendar.messages;

import calendar.User;
import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;

/* this class represents a calendar event */
import java.util.ArrayList;
public class ScheduleResponse implements Message
{ 
  public ArrayList users;

  public ScheduleResponse()
  {
    this.users = null;
  }


  public void marshal(BlockOutputStream stream) throws IOException
  {
    boolean isNull = (users == null);
    stream.writeBoolean(isNull);
      
    if ( isNull == false )
    {
        stream.writeInt( this.users.size() );
        for (int i = 0; i < users.size(); i++)
        {
            User user = (User)users.get(i);
            user.marshal(stream);
        }
    }
  }

  public void unmarshal(BlockInputStream stream) throws IOException
  {
      boolean isNull = stream.readBoolean();
      if( isNull == false )
      {
        int size = stream.readInt();
        this.users = new ArrayList();
        for (int i = 0; i < size; i++)
        {
            User user = new User();
            user.unmarshal(stream);
            this.users.add(user);
        }
      }
  }
}
